//do phase shift by FFT.
//block.rptr(1) indicates the phase shift in degree. 
//assume that phase shifter is to shift a real signal by d degree.
//it shifts negative frequency by -d degree, shift positive frequency by d degree.
//so in frequency domain, multiply negative frequency by exp(%i*(-d)/180*%pi).
//multiply positive frequency by exp(%i*(d)/180*%pi).

//xn is time domain real signal.
//xk is xn's DFT.
//assum xk's length is N, (0..N/2-1) associate with frequency > 0, (N/2..N-1) associate frequency < 0.
//xk_trans: multiply first half points in xk(0..N/2-1) by exp(%i*block.rpar(1)/180*%pi), 
//			multiply the second half points in xk by exp(%i*(-block.rpar(1))/180*%pi).
//xn_trans: ifft of xk_trans
//the real part of xn_trans is time domain signal after phase shifting.

function block = phaseShifter_com(block, flag)
	if flag == 1 then
		block.outptr(1)(:) = block.z(:);
	elseif flag == 2 then
		len = block.insz(1);
		xn = block.inptr(1)(:);
		xk = fft(xn);
		phase = exp(%i*block.rpar(1)/180*%pi);
		xk_trans = [xk(1:len/2)*phase; xk(len/2+1 : len)*conj(phase)];
		xn_trans = ifft(xk_trans);
		block.z(:) = real(xn_trans);
	end
endfunction 
